Skip to content

chore: deprecate insightsProject.repositories and use repositories [CM-911]#3806

Merged
mbani01 merged 3 commits intomainfrom
chore/full_deprecation_of_insightsProjectRepositories
Jan 30, 2026
Merged

chore: deprecate insightsProject.repositories and use repositories [CM-911]#3806
mbani01 merged 3 commits intomainfrom
chore/full_deprecation_of_insightsProjectRepositories

Conversation

@mbani01
Copy link
Contributor

@mbani01 mbani01 commented Jan 30, 2026

This pull request refactors the way repository data is managed and synchronized between backend and frontend, focusing on removing the direct use of the insightsProject.repositories field and instead relying on the repositories.enabled status for repository selection. The changes streamline repository management, improve data consistency, and simplify the update flow for insights projects.

Backend refactoring and data model changes:

  • Removed logic that directly updates or syncs the repositories field on insightsProject objects, including the removal of the syncGithubRepositoriesToInsights method and related update flows in IntegrationService. [1] [2] [3] [4] [5]
  • Updated repository data fetching and grouping functions to include an enabled boolean flag for each repo, reflecting whether the repository is active for the project. This affects the return types and data structures in getReposBySegmentGroupedByPlatform, findRepositoriesForSegment, and related interfaces. [1] [2] [3] [4] [5]
  • Modified the update logic for insights projects so that repository enablement is managed via the repositories.enabled field in the public.repositories table, rather than updating a list of URLs on the insights project itself. [1] [2]

Frontend adjustments:

  • Simplified the form-building logic for insights projects to use the new repository structure, removing the logic that mapped and enabled repositories based on the insights project’s repositories field.
  • Updated repository-building utilities to handle the new enabled flag in the repository objects, ensuring that the UI reflects the actual enablement status from the backend. [1] [2]

Code cleanup and removal of deprecated logic:

  • Removed unused imports and methods related to the old repository sync flow, including the syncGithubReposToInsights activity and its references across the codebase. [1] [2] [3] [4]

These changes collectively ensure that repository enablement is now consistently managed via the enabled field in the repositories table, improving the reliability and clarity of repository management in both backend and frontend systems.


Note

Medium Risk
This changes how repo selection is persisted (moving from an InsightsProject URL list to public.repositories.enabled) and removes an existing GitHub-to-insights sync path, which could affect which repos appear enabled if any callers still rely on the deprecated field.

Overview
Stops treating insightsProjects.repositories as the source of truth for repo selection and instead relies on public.repositories.enabled.

Backend updates remove repo-list syncing during integration create/update and delete the CommonIntegrationService.syncGithubRepositoriesToInsights + related Nango worker activity/workflow calls; updateInsightsProject no longer writes the repositories list, and the DAL updateInsightsProject ignores DB updates to the repositories column while still using an optional repositories input to toggle public.repositories.enabled.

Repository lookup APIs now return {url,label,enabled} (including a new enabled field propagated from SQL), and the admin UI helpers are simplified to consume/preserve that enabled flag when building and merging repository lists.

Written by Cursor Bugbot for commit 3fb69ee. This will update automatically on new commits. Configure here.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors insights project repository selection to stop relying on insightsProjects.repositories and instead use public.repositories.enabled as the source of truth for which repos are active.

Changes:

  • Adds enabled to repository-fetching/grouping responses and threads it through DAL → API → UI.
  • Updates insights project update flow to sync public.repositories.enabled (and avoids writing insightsProjects.repositories).
  • Removes deprecated GitHub repo sync activity/service code and related backend wiring.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
services/libs/data-access-layer/src/utils.ts Makes updateTableById resilient when there are no updatable fields (still updates updatedAt).
services/libs/data-access-layer/src/segments/index.ts Extends repo grouping query/return type to include enabled.
services/libs/data-access-layer/src/repositories/index.ts Updates doc comment for syncRepositoriesEnabledStatus to reflect new usage.
services/libs/data-access-layer/src/integrations/index.ts Propagates enabled through findRepositoriesForSegment and updates return type.
services/libs/data-access-layer/src/collections/index.ts Stops updating insightsProjects.repositories; syncs public.repositories.enabled when repositories is provided.
services/libs/common_services/src/services/integration.service.ts Removes deprecated syncGithubRepositoriesToInsights flow.
services/apps/nango_worker/src/workflows/syncGithubIntegration.ts Removes post-sync activity call for deprecated insights project repo syncing.
services/apps/nango_worker/src/activities/nangoActivities.ts Removes deprecated activity and unused service import.
services/apps/nango_worker/src/activities.ts Removes export for deleted activity.
frontend/src/modules/admin/modules/insights-projects/insight-project-helper.ts Updates form/repo utilities to rely on backend-provided enabled instead of insightsProjects.repositories.
backend/src/services/integrationService.ts Removes insights-project repository syncing and stops writing data.repositories during integration updates.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 670 to 674
for (const [platform, repos] of Object.entries(reposByPlatform)) {
result[platform] = repos.map((repo) => ({
url: normalizeRepoUrl(repo.url),
label: extractLabelFromUrl(repo.url),
enabled: repo.enabled,
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

findRepositoriesForSegment returns url: normalizeRepoUrl(repo.url), but the url value is later used as the identifier the UI sends back when updating an insights project’s enabled repos. Since normalizeRepoUrl can change the string (e.g., http→https, remove www., strip .git/trailing slashes), the incoming enabled URL list may no longer exactly match public.repositories.url, causing syncRepositoriesEnabledStatus to disable repos unexpectedly. Consider returning the raw stored repo.url as the identifier (and only normalize for label/display), or ensure URLs are normalized at write-time so stored and returned values round-trip consistently.

Copilot uses AI. Check for mistakes.
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

qx: QueryExecutor,
segmentId: string,
): Promise<Record<string, Array<{ url: string; label: string }>>> {
): Promise<Record<string, Array<{ url: string; label: string; enabled: boolean }>>> {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused exported function after refactoring

Low Severity

The normalizeRepoUrl function is exported but no longer used anywhere in the codebase. This PR removed its only usage in findRepositoriesForSegment (which previously called normalizeRepoUrl(url) but now uses repo.url directly), leaving the function as dead code. The function can be safely removed unless it's intended for future use.

Fix in Cursor Fix in Web

insightsProjectId,
isFirstUpdate: true,
platform,
repositories,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mbani01 just to double check, we don't need to re-update the insightsProject anymore here ? the data is already synced?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No we don't need to re-update repositories, since the enabled is field in public.repositories is by default set to true

@mbani01 mbani01 merged commit de40533 into main Jan 30, 2026
16 checks passed
@mbani01 mbani01 deleted the chore/full_deprecation_of_insightsProjectRepositories branch January 30, 2026 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants